package Scrap;

import java.util.Scanner;

public class demo22_stackdemo {

	static int st = -1;
	int stk[] = new int[6];

	public static void main(String[] args) {
		// Scanner sc = new Scanner(System.in);
		// int stack_length = sc.nextInt();

		// int stack_length = 6;
		// for (int i = 0; i < stk.length; i++) {
		//
		// System.out.println(stk[i]);
		// }
		demo22_stackdemo d = new demo22_stackdemo();
		d.push(22);
		d.push(12);
		d.push(45);
		d.push(676);
		// d.push(109);
		d.pop();
		d.pop();

		d.print();

	}

	void push(int v) {

		if (st < stk.length) {

			st++;
			stk[st] = v;

		} else {

			System.out.println("Stack Overflow");

		}

	}

	void print() {

		while (st >= 0) {
			System.out.println(stk[st]);

			st--;
		}

	}

	void pop() {

		if (st > 0) {
			stk[st] = 0;
			st--;
		} else if (st == 0) {
			stk[st] = 0;
			st--;
			System.out.println("Stack is empty");

		} else {
			System.out.println("Stack Underflow");
		}

	}

}
